---------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  C:\Users\sbstjp\OneDrive - Cardiff University\FinalHarvard\Appendix2.10.log
  log type:  text
 opened on:  12 May 2025, 17:32:44

. 
. use "C:\Users\sbstjp\OneDrive - Cardiff University\Transgender IAT.public.2023.dta" // Project Implicit Demo 
> Website Datasets, Transgender IAT, Last Updated: 2025-01-13 10:29 PM. Date accessed: March 09, 2025. SPSS ver
> sion of the dataset downloaded and then, without alterations, converted to a Stata file. 

. 
. // Create the scale
. *Standardize items in the scale from 1-2 - this puts the scale on the same scale as others in the book and av
> oids 0, for reasons outlined in next step
. foreach var in transphobia1 transphobia2 transphobia3 transphobia4 transphobia5 transphobia6 transphobia7 tra
> nsphobia8 transphobia9 {
  2.     summarize `var'
  3.     gen s`var' = 1 + (`var' - r(min)) / (r(max) - r(min))
  4. }

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
transphobia1 |     34,328    3.449196    2.102671          1          7
(130,468 missing values generated)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
transphobia2 |     34,555     2.90531    2.128383          1          7
(130,241 missing values generated)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
transphobia3 |     34,584    2.489128    1.882335          1          7
(130,212 missing values generated)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
transphobia4 |     34,614      2.1697    1.633664          1          7
(130,182 missing values generated)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
transphobia5 |     34,590    3.254235    2.006424          1          7
(130,206 missing values generated)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
transphobia6 |     33,918    3.875317    2.066812          1          7
(130,878 missing values generated)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
transphobia7 |     34,561    2.295564    1.677239          1          7
(130,235 missing values generated)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
transphobia8 |     34,543    2.759343    2.179396          1          7
(130,253 missing values generated)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
transphobia9 |     34,526    3.348896    2.375235          1          7
(130,270 missing values generated)

. 
. * Replace missing values with 0 for the specified variables - this is necessary as Stata doesn't add up missi
> ng values
. foreach var in stransphobia1 stransphobia2 stransphobia3 stransphobia4 stransphobia5 stransphobia6 stransphob
> ia7 stransphobia8 stransphobia9 {
  2.     replace `var' = 0 if missing(`var')
  3. }
(130,468 real changes made)
(130,241 real changes made)
(130,212 real changes made)
(130,182 real changes made)
(130,206 real changes made)
(130,878 real changes made)
(130,235 real changes made)
(130,253 real changes made)
(130,270 real changes made)

. 
. * Initialize the total score and the count of non-zero responses
. gen total_scoreTP = 0

. gen count_nonzeroTP = 0

. 
. * Add each variable to the total scale score and count it if non-zero
. foreach var in stransphobia1 stransphobia2 stransphobia3 stransphobia4 stransphobia5 stransphobia6 stransphob
> ia7 stransphobia8 stransphobia9 {
  2.     replace total_scoreTP = total_scoreTP + `var'
  3.     replace count_nonzeroTP = count_nonzeroTP + (`var' != 0)
  4. }
(34,328 real changes made)
(34,328 real changes made)
(34,555 real changes made)
(34,555 real changes made)
(34,584 real changes made)
(34,584 real changes made)
(34,614 real changes made)
(34,614 real changes made)
(34,590 real changes made)
(34,590 real changes made)
(33,918 real changes made)
(33,918 real changes made)
(34,561 real changes made)
(34,561 real changes made)
(34,543 real changes made)
(34,543 real changes made)
(34,526 real changes made)
(34,526 real changes made)

. 
. * Calculate the average score, avoiding division by zero
. gen TPScale = .
(164,796 missing values generated)

. replace TPScale = total_scoreTP / count_nonzeroTP if count_nonzeroTP > 0
(34,996 real changes made)

. 
. * Reverse so social justice values are coded high
. qui sum TPScale

. gen NonTransphobia = r(max) + 1 - TPScale
(129,800 missing values generated)

. 
. // Demographics
. *This is a convenience sample and under 18s have completed it. But we're studying voters so drop under 18s.
. drop if birthyear>2005 
(22,369 observations deleted)

. gen age = 2023 - birthyear 

. *Drop as probably misreported age
. drop if age>100
(1,107 observations deleted)

.  
. * Rename variables and create dummies
. rename birthSex FemaleGender

. 
. gen Graduate=.
(141,320 missing values generated)

. replace Graduate=0 if inrange(edu_14, 1, 6)
(46,525 real changes made)

. replace Graduate=1 if inrange(edu_14, 7, 14)
(51,333 real changes made)

. 
. gen BIPOC=.
(141,320 missing values generated)

. replace BIPOC=0 if raceomb_002==6
(18,822 real changes made)

. replace BIPOC=1 if inrange(raceomb_002, 1, 5)
(3,961 real changes made)

. replace BIPOC=1 if inrange(raceomb_002, 7, 8)
(2,757 real changes made)

. 
. *Sociocultural employment dummy
. gen occuSelfDetail_clean = real(subinstr(occuSelfDetail, "-", "", .))
(66,870 missing values generated)

. gen SocCulEmployment=.
(141,320 missing values generated)

. replace SocCulEmployment=0 if inrange(occuSelfDetail_clean, 431000, 439000)
(4,427 real changes made)

. replace SocCulEmployment=0 if inrange(occuSelfDetail_clean, 131000, 132000)
(4,488 real changes made)

. replace SocCulEmployment=0 if inrange(occuSelfDetail_clean, 151000, 153000)
(2,317 real changes made)

. replace SocCulEmployment=0 if inrange(occuSelfDetail_clean, 171000, 173000)
(2,015 real changes made)

. replace SocCulEmployment=0 if inrange(occuSelfDetail_clean, 471000, 475000)
(584 real changes made)

. replace SocCulEmployment=0 if inrange(occuSelfDetail_clean, 451000, 459000)
(516 real changes made)

. replace SocCulEmployment=0 if inrange(occuSelfDetail_clean, 351000, 359000)
(5,562 real changes made)

. replace SocCulEmployment=0 if inrange(occuSelfDetail_clean, 371000, 373000)
(363 real changes made)

. 
. replace SocCulEmployment=0 if inrange(occuSelfDetail_clean, 110000, 119000)
(3,722 real changes made)

. replace SocCulEmployment=0 if inrange(occuSelfDetail_clean, 551000, 553000)
(915 real changes made)

. replace SocCulEmployment=0 if inrange(occuSelfDetail_clean, 511000, 519000)
(658 real changes made)

. replace SocCulEmployment=0 if inrange(occuSelfDetail_clean, 451000, 459000)
(0 real changes made)

. replace SocCulEmployment=0 if inrange(occuSelfDetail_clean, 331000, 332000)
(105 real changes made)

. replace SocCulEmployment=0 if occuSelfDetail_clean==339000
(249 real changes made)

. 
. replace SocCulEmployment=0 if inrange(occuSelfDetail_clean, 491000, 499000)
(241 real changes made)

. replace SocCulEmployment=0 if inrange(occuSelfDetail_clean, 411000, 419000)
(4,044 real changes made)

. replace SocCulEmployment=0 if inrange(occuSelfDetail_clean, 191000, 192000)
(1,228 real changes made)

. replace SocCulEmployment=0 if inrange(occuSelfDetail_clean, 531000, 537000)
(400 real changes made)

. replace SocCulEmployment=0 if occuSelfDetail_clean==194000
(181 real changes made)

. 
. replace SocCulEmployment=1 if inrange(occuSelfDetail_clean, 271000, 274000)
(3,334 real changes made)

. replace SocCulEmployment=1 if inrange(occuSelfDetail_clean, 251000, 259000)
(11,051 real changes made)

. replace SocCulEmployment=1 if inrange(occuSelfDetail_clean, 291000, 292000)
(3,378 real changes made)

. replace SocCulEmployment=1 if inrange(occuSelfDetail_clean, 311000, 319000)
(11,388 real changes made)

. replace SocCulEmployment=1 if inrange(occuSelfDetail_clean, 231000, 232000)
(1,773 real changes made)

. replace SocCulEmployment=1 if inrange(occuSelfDetail_clean, 391000, 399000)
(1,367 real changes made)

. replace SocCulEmployment=1 if inrange(occuSelfDetail_clean, 211000, 212000)
(5,093 real changes made)

. replace SocCulEmployment=1 if occuSelfDetail_clean==333000
(559 real changes made)

. replace SocCulEmployment=1 if occuSelfDetail_clean==193000
(377 real changes made)

. 
. // Standardize
. egen Age = std(age) 

. 
. // Create a weight
. 
. gen weight = 1

. 
. * Code age into categories - the other variables are already in such categories
. recode age (min/24=1 "0-24") (25/34=2 "25-34") (35/44=3 "35-44") (45/54=4 "45-54") (55/max=5 "55+"), generate
> (age_group)
(141320 differences between age and age_group)

. 
. * The below are based on census data, except for ideology, which is based on data from the ANES24 pilot study
. gen sextot=.
(141,320 missing values generated)

. replace sextot = 0.49 if FemaleGender == 1 // Male
(8,268 real changes made)

. replace sextot = 0.51 if FemaleGender == 2 // Female
(18,591 real changes made)

. 
. gen agetot=.
(141,320 missing values generated)

. replace agetot = 0.12 if age_group == 1 // 18-24
(60,351 real changes made)

. replace agetot = 0.17 if age_group == 2 // 25-34
(34,665 real changes made)

. replace agetot = 0.17 if age_group == 3 // 35-44
(21,250 real changes made)

. replace agetot = 0.16 if age_group == 4 // 45-54
(15,010 real changes made)

. replace agetot = 0.38 if age_group == 5 // 55+
(10,044 real changes made)

. 
. gen idtot=.
(141,320 missing values generated)

. replace idtot = 0.08 if politicalid_7 == 1 // Strongly conservative
(3,579 real changes made)

. replace idtot = 0.17 if politicalid_7 == 2 // Moderately conservative
(8,219 real changes made)

. replace idtot = 0.08 if politicalid_7 == 3 // Slightly conservative
(7,997 real changes made)

. replace idtot = 0.33 if politicalid_7 == 4 // Neutral
(24,213 real changes made)

. replace idtot = 0.08 if politicalid_7 == 5 // Slightly liberal
(10,502 real changes made)

. replace idtot = 0.18 if politicalid_7 == 6 // Moderately liberal
(26,285 real changes made)

. replace idtot = 0.08 if politicalid_7 == 7 // Strongly liberal
(20,508 real changes made)

. 
. gen edcats=.
(141,320 missing values generated)

. replace edcats=1 if inrange(edu_14, 1, 4) // Highschoolandbelow
(17,593 real changes made)

. replace edcats=2 if inrange(edu_14, 5, 6) // Somecollege
(28,932 real changes made)

. replace edcats=3 if edu_14==7 // Bachelors
(22,332 real changes made)

. replace edcats=4 if inrange(edu_14, 8, 14) // Graduate
(29,001 real changes made)

. 
. gen edtot=.
(141,320 missing values generated)

. replace edtot = 0.3875 if edcats == 1
(17,593 real changes made)

. replace edtot = 0.2644 if edcats == 2
(28,932 real changes made)

. replace edtot = 0.2208 if edcats == 3
(22,332 real changes made)

. replace edtot = 0.1273 if edcats == 4
(29,001 real changes made)

. 
. gen ethcats=.
(141,320 missing values generated)

. replace ethcats=1 if raceomb_002==1 //AmericanIndian/AlaskaNative
(212 real changes made)

. replace ethcats=2 if inrange(raceomb_002, 2, 3) //Asian
(1,653 real changes made)

. replace ethcats=3 if raceomb_002==4 //NativeHawaiian
(146 real changes made)

. replace ethcats=4 if raceomb_002==5 //Black
(1,950 real changes made)

. replace ethcats=5 if raceomb_002==6 //White
(18,822 real changes made)

. replace ethcats=6 if raceomb_002==7 //Other
(1,406 real changes made)

. replace ethcats=7 if raceomb_002==8 //Multiracial
(1,351 real changes made)

. 
. gen ethtot=.
(141,320 missing values generated)

. replace ethtot = 0.01 if ethcats == 1
(212 real changes made)

. replace ethtot = 0.0599 if ethcats == 2
(1,653 real changes made)

. replace ethtot = 0.002 if ethcats == 3
(146 real changes made)

. replace ethtot = 0.1213 if ethcats == 4
(1,950 real changes made)

. replace ethtot = 0.6051 if ethcats == 5
(18,822 real changes made)

. replace ethtot = 0.0742 if ethcats == 6
(1,406 real changes made)

. replace ethtot = 0.1276 if ethcats == 7
(1,351 real changes made)

. 
. survwgt rake weight , by(FemaleGender age_group politicalid_7 ethcats edcats) totvars(sextot agetot idtot eth
> tot edtot) generate(rakedweight)

. 
. // Regression
. regress NonTransphobia Age BIPOC FemaleGender Graduate SocCulEmployment [pweight=rakedweight], robust
(sum of wgt is .2255378878043094)

Linear regression                               Number of obs     =      5,298
                                                F(5, 5292)        =      12.34
                                                Prob > F          =     0.0000
                                                R-squared         =     0.0527
                                                Root MSE          =     .23049

----------------------------------------------------------------------------------
                 |               Robust
  NonTransphobia | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-----------------+----------------------------------------------------------------
             Age |  -.0334073   .0063896    -5.23   0.000    -.0459336    -.020881
           BIPOC |  -.0309425   .0172258    -1.80   0.073    -.0647122    .0028272
    FemaleGender |   .0744016   .0163129     4.56   0.000     .0424216    .1063817
        Graduate |   .0440613   .0143255     3.08   0.002     .0159775    .0721452
SocCulEmployment |  -.0030308   .0160908    -0.19   0.851    -.0345754    .0285138
           _cons |    1.50068   .0278386    53.91   0.000     1.446105    1.555255
----------------------------------------------------------------------------------

. eststo
(est1 stored)

. esttab

----------------------------
                      (1)   
             NonTransph~a   
----------------------------
Age               -0.0334***
                  (-5.23)   

BIPOC             -0.0309   
                  (-1.80)   

FemaleGender       0.0744***
                   (4.56)   

Graduate           0.0441** 
                   (3.08)   

SocCulEmpl~t     -0.00303   
                  (-0.19)   

_cons               1.501***
                  (53.91)   
----------------------------
N                    5298   
----------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

. 
. log close
      name:  <unnamed>
       log:  C:\Users\sbstjp\OneDrive - Cardiff University\FinalHarvard\Appendix2.10.log
  log type:  text
 closed on:  12 May 2025, 17:33:15
---------------------------------------------------------------------------------------------------------------
